<table class="easyui-datagrid" id="salesorder_list"
       fit="true" border="false"
       singleSelect="true" fitColumns="true" pagination="true"
       idField="salesorder_id" url="y.php?r=salesorder/getdata" toolbar="#toolbar_salesorder">
    <thead>
    <tr>
        <th field="salesorder_number" width="60">销售订单号</th>
        <th field="stage" width="60">订单状态</th>
        <th field="customer" width="60">客户</th>
        <th field="contacter" width="60">联系人</th>
        <th field="signdate" width="60">签约日期</th>
        <th field="total" width="60">总计</th>
        <th field="gather_status" width="60">收款状态</th>
    </tr>
    </thead>
</table>
<div id="toolbar_salesorder">
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="loadWin('添加合同订单','y.php?r=salesorder/showedit&salesorder_id=0')" /a>
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true" onclick="salesorder_showedit()"/a>
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="salesorder_remove()" />
</div>
<script>
    function salesorder_showedit() {
        //获取选中的列
        var selected = $("#salesorder_list").datagrid("getSelected");
        if(selected==null){
            alert('请选择行！');
        }else{
            //进行编辑操作
            loadWin('编辑合同订单','y.php?r=salesorder/showedit&salesorder_id='+selected.salesorder_id);
        }
    }
    function salesorder_remove() {
        var selected = $("#salesorder_list").datagrid("getSelected");
        if(selected==null){
            alert('请选择行！');
        }else{
            $.messager.confirm('确认','您确认想要删除记录吗？',function(r){
                if (r){
                    $.post('y.php?r=salesorder/remove',{salesorder_id:selected.salesorder_id},function (res) {
                        $("#salesorder_list").datagrid("reload");
                    });
                }
            });
        }
    }
</script>